<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>Event活动编辑</title>
        <script type="text/javascript" src="../../inc/ctx.jsp"></script>
        <script type="text/javascript" src="../js/g.js"></script>
        <script type="text/javascript" src="../js/cmstype.js"></script>
        <script type="text/javascript" src="http://cdn.uuola.cn/js/formvalid.js" charset="utf-8"></script>
        <link rel="stylesheet" href="../../ked/js/themes/default/default.css" />
        <link rel="stylesheet" href="../../ked/js/plugins/code/prettify.css" />
        <script charset="utf-8" src="../../ked/js/kindeditor-min.js"></script>
        <script charset="utf-8" src="../../ked/js/zh_CN.js"></script>
        <script charset="utf-8" src="../../ked/js/plugins/code/prettify.js"></script>
        <script type="text/javascript" src="../js/channeltype.js"></script>
        <link href="../css/com.css" type="text/css" rel="stylesheet"/>
        <style>
            img.s1{width:100px;border:1px #EFEFEF solid;padding:1px;}
            #panel{width:950px;}
            #panel table{width:940px;}
            span.s1{color:#B1B1B1;}
            #submitBtn{width:150px;height:35px;}
        </style>
    </head>
    <body>

        <div id="panel">
            <form id="editFrm" name="editFrm">
                <input type="hidden" value="" name="id" id="id" />
                <table>
                    <tr>
                        <th colspan="3">编辑信息</th>
                    </tr>
                    <tr>
                        <td class="r">所属板块：</td>
                        <td><span id="channeltype"></span></td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td width="180" height="27" class="r">活动标题：</td>
                        <td width="49%">
                            <input name="eventname" type="text" id="eventname" tabindex="1" size="50" maxlength="60" valid="required" errmsg="信息标题不能为空!" />* 
                        </td>
                        <td width="34%"><div id="err_eventname"><span class="s1">信息标题.60个字符内.勿使用特殊字符.</span></div></td>
                    </tr>
                    <tr>
                        <td class="r">作者/发布者：</td>
                        <td><input name="author" type="text" id="author" tabindex="7" maxlength="30"></td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="r">cms类型：</td>
                        <td><script>out_cmstype();</script></td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="r">信息主图：</td>
                        <td><label for="pic"></label>
                            <input name="pic" type="text" id="pic" size="50">
                            <input type="button" name="uploadBtn" id="uploadBtn" value="上传图片" tabindex="5" onclick="TxBox.upload('pic', '-ms-ss-', '');">
                        </td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="r">跳转地址：</td>
                        <td><label for="gotourl"></label>
                            <input name="gotourl" type="text" id="gotourl" size="50">
                        </td>
                        <td>&nbsp;<span class="s1">跳转地址以http://开头</span></td>
                    </tr>
                    <tr>
                        <td class="r">信息内容：</td>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="r" colspan="3">
                            <textarea name="content" id="content" cols="150" rows="20"></textarea></td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td></td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td class="r">&nbsp;</td>
                        <td class="c"><input name="submitBtn" type="button" class="button medium orange" id="submitBtn" tabindex="7" value="保存信息" onClick="Events.submit();" /></td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td class="c"></td>
                        <td>&nbsp;</td>
                    </tr>
                </table>
            </form>
        </div>



        <script type="text/javascript">
            var id = ut.get('id');
            var frm = ut.e('editFrm');
            initValid(frm);
            
            function initFormData(){
                if(va.isnull(id)){
                    ut.m('信息ID参数错误');
                    return;
                }
                var p={'id':id,'t':ut.r()};
                $.get('../app/events/query_event_edit.shtm',$.param(p),function(x){
                    if(typeof x == 'string'){
                        ut.m('初始化表单错误.'+x);
                        return;
                    }
                    $('#id').val(id);
                    $('#channeltype').text(getChannelType(x.channeltype));
                    $('#eventname').val(x.eventname);
                    $('#author').val(x.author);
                    $('#cmstype').val(x.cmstype);
                    $('#pic').val(x.pic);
                    $('#gotourl').val(x.gotourl);
                    contentEditor.html(x.content);
                });
            };
            
            // 初始化编辑器
            var contentEditor ; 
            KindEditor.ready(function(K) {
                contentEditor = K.create('#content', {
                    uploadJson : KindUpload.UploadUrl,
                    fileManagerJson : KindUpload.fileMgrUrl,
                    allowFileManager : true,
                    afterCreate : function() {
                        var self = this;
                        self.sync();
                    }
                });
                prettyPrint();
                initFormData();
            });
            
            var Events ={
                submit:function(){
                    contentEditor.sync();
                    if(validator(frm)){
                        $.post('../app/events/update.shtm',ut.getFormData('#editFrm'),function(x){
                            if($.trim(x)=='ok'){
                                ut.m('更新成功!');
                                win.close();
                            }else{
                                ut.m('更新失败. '+x);
                            }   
                        });
                    }
                }
            };     


        </script>
    </body>
</html>
